import React from "react";
import { NavBar } from "antd-mobile";
// 引入校验 prop-types
import PropTypes from "prop-types";

import { withRouter } from "react-router-dom";

import classNames from "classnames";

import styles from "./index.module.scss";

function NavHeader(props) {
//   console.log(props.className);

  return (
    <NavBar
      // className={classNames(`${styles.navBar} ${props.className}`)}
      className={classNames(styles.navBar,{[props.className]: !!props.className})}
      // 模式
      mode="light"
      //  左边 icon 图标
      icon={<i className="iconfont icon-back"></i>}
      onLeftClick={() => props.history.go(-1)}
    >
      {props.children}
    </NavBar>
  );
}
// 校验
NavHeader.propTypes = {
  // 约定 children 为 字符串类型，并且为必填项
  children: PropTypes.string.isRequired
};

export default withRouter(NavHeader);
